
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/26/2014 10:25:45
-- Generated from EDMX file: D:\Learning\DeTaiTotNghiep\h-invoicing\Source\FinalProject.DAL\Mapping\InvoiceModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [InvoiceData];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_OrderDocumentDeliveryDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeliveryDocuments] DROP CONSTRAINT [FK_OrderDocumentDeliveryDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_DeliveryDocumentInvoiceDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[InvoiceDocuments] DROP CONSTRAINT [FK_DeliveryDocumentInvoiceDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoiceDocumentCollectionMoney]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CollectionMoneys] DROP CONSTRAINT [FK_InvoiceDocumentCollectionMoney];
GO
IF OBJECT_ID(N'[dbo].[FK_VoucherCollectionMoney]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CollectionMoneys] DROP CONSTRAINT [FK_VoucherCollectionMoney];
GO
IF OBJECT_ID(N'[dbo].[FK_DeliveryDocumentDocumentRow]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DocumentRows] DROP CONSTRAINT [FK_DeliveryDocumentDocumentRow];
GO
IF OBJECT_ID(N'[dbo].[FK_InvoiceDocumentDocumentRow]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DocumentRows] DROP CONSTRAINT [FK_InvoiceDocumentDocumentRow];
GO
IF OBJECT_ID(N'[dbo].[FK_OrderDocumentDocumentRow]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DocumentRows] DROP CONSTRAINT [FK_OrderDocumentDocumentRow];
GO
IF OBJECT_ID(N'[dbo].[FK_ItemDocumentRow]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DocumentRows] DROP CONSTRAINT [FK_ItemDocumentRow];
GO
IF OBJECT_ID(N'[dbo].[FK_JournalJournalType]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Journals] DROP CONSTRAINT [FK_JournalJournalType];
GO
IF OBJECT_ID(N'[dbo].[FK_JournalInvoiceDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[InvoiceDocuments] DROP CONSTRAINT [FK_JournalInvoiceDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_JournalVoucher]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Vouchers] DROP CONSTRAINT [FK_JournalVoucher];
GO
IF OBJECT_ID(N'[dbo].[FK_CustomerOrderDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[OrderDocuments] DROP CONSTRAINT [FK_CustomerOrderDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_CustomerDeliveryDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeliveryDocuments] DROP CONSTRAINT [FK_CustomerDeliveryDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_CustomerInvoiceDocument]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[InvoiceDocuments] DROP CONSTRAINT [FK_CustomerInvoiceDocument];
GO
IF OBJECT_ID(N'[dbo].[FK_CustomerVoucher]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Vouchers] DROP CONSTRAINT [FK_CustomerVoucher];
GO
IF OBJECT_ID(N'[dbo].[FK_WarehouseItem]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Items] DROP CONSTRAINT [FK_WarehouseItem];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[OrderDocuments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[OrderDocuments];
GO
IF OBJECT_ID(N'[dbo].[DeliveryDocuments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeliveryDocuments];
GO
IF OBJECT_ID(N'[dbo].[InvoiceDocuments]', 'U') IS NOT NULL
    DROP TABLE [dbo].[InvoiceDocuments];
GO
IF OBJECT_ID(N'[dbo].[DocumentRows]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DocumentRows];
GO
IF OBJECT_ID(N'[dbo].[Items]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Items];
GO
IF OBJECT_ID(N'[dbo].[Warehouses]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Warehouses];
GO
IF OBJECT_ID(N'[dbo].[Journals]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Journals];
GO
IF OBJECT_ID(N'[dbo].[JournalTypes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[JournalTypes];
GO
IF OBJECT_ID(N'[dbo].[Customers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Customers];
GO
IF OBJECT_ID(N'[dbo].[Vouchers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Vouchers];
GO
IF OBJECT_ID(N'[dbo].[CollectionMoneys]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CollectionMoneys];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'OrderDocuments'
CREATE TABLE [dbo].[OrderDocuments] (
    [Id] uniqueidentifier  NOT NULL,
    [DocNumber] bigint  NOT NULL,
    [DocDate] datetime  NOT NULL,
    [DocAddress] nvarchar(max)  NULL,
    [DeliveryDate] datetime  NOT NULL,
    [TotalAmount] decimal(18,0)  NOT NULL,
    [PayMode] smallint  NOT NULL,
    [VATRate] float  NOT NULL,
    [CustomerId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'DeliveryDocuments'
CREATE TABLE [dbo].[DeliveryDocuments] (
    [Id] uniqueidentifier  NOT NULL,
    [DocNumber] bigint  NOT NULL,
    [DocDate] datetime  NOT NULL,
    [TotalAmount] decimal(18,0)  NOT NULL,
    [Desciption] nvarchar(max)  NULL,
    [OrderDocumentId] uniqueidentifier  NOT NULL,
    [CustomerId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'InvoiceDocuments'
CREATE TABLE [dbo].[InvoiceDocuments] (
    [Id] uniqueidentifier  NOT NULL,
    [DocNumber] int  NOT NULL,
    [DocDate] datetime  NOT NULL,
    [TotalAmount] decimal(18,0)  NOT NULL,
    [VATRate] float  NOT NULL,
    [PayMode] smallint  NOT NULL,
    [DeliveryDocumentId] uniqueidentifier  NOT NULL,
    [JournalId] uniqueidentifier  NOT NULL,
    [CustomerId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'DocumentRows'
CREATE TABLE [dbo].[DocumentRows] (
    [Id] uniqueidentifier  NOT NULL,
    [RowNumber] nvarchar(max)  NOT NULL,
    [UnitPrice] nvarchar(max)  NOT NULL,
    [Quantity] nvarchar(max)  NOT NULL,
    [TotalAmount] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [DeliveryDocumentId] uniqueidentifier  NOT NULL,
    [InvoiceDocumentId] uniqueidentifier  NOT NULL,
    [OrderDocumentId] uniqueidentifier  NOT NULL,
    [ItemId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'Items'
CREATE TABLE [dbo].[Items] (
    [Id] uniqueidentifier  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [LotNumber] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [WarehouseId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'Warehouses'
CREATE TABLE [dbo].[Warehouses] (
    [Id] uniqueidentifier  NOT NULL,
    [Name] nvarchar(max)  NULL,
    [Address] nvarchar(max)  NULL,
    [Code] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Journals'
CREATE TABLE [dbo].[Journals] (
    [Id] uniqueidentifier  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [CreateDate] nvarchar(max)  NOT NULL,
    [JournalTypeId] uniqueidentifier  NOT NULL,
    [Code] nvarchar(max)  NOT NULL,
    [JournalType_Id] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'JournalTypes'
CREATE TABLE [dbo].[JournalTypes] (
    [Id] uniqueidentifier  NOT NULL,
    [Name] nvarchar(max)  NULL,
    [Code] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Customers'
CREATE TABLE [dbo].[Customers] (
    [Id] uniqueidentifier  NOT NULL,
    [Name] nvarchar(max)  NULL,
    [Address] nvarchar(max)  NULL,
    [IBAN] nvarchar(max)  NULL,
    [PhoneNumber] nvarchar(max)  NULL,
    [FaxNumber] nvarchar(max)  NULL,
    [Delegate] nvarchar(max)  NULL,
    [TaxCode] nvarchar(max)  NULL,
    [MaxDebit] decimal(18,0)  NOT NULL,
    [Code] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Vouchers'
CREATE TABLE [dbo].[Vouchers] (
    [Id] uniqueidentifier  NOT NULL,
    [VoucherNumber] nvarchar(max)  NOT NULL,
    [CurrencyRate] nvarchar(max)  NOT NULL,
    [TotalAmount] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [JournalId] uniqueidentifier  NOT NULL,
    [CustomerId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'CollectionMoneys'
CREATE TABLE [dbo].[CollectionMoneys] (
    [Id] uniqueidentifier  NOT NULL,
    [Amount] decimal(18,0)  NOT NULL,
    [Desciption] nvarchar(max)  NOT NULL,
    [InvoiceDocumentId] uniqueidentifier  NOT NULL,
    [VoucherId] uniqueidentifier  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'OrderDocuments'
ALTER TABLE [dbo].[OrderDocuments]
ADD CONSTRAINT [PK_OrderDocuments]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DeliveryDocuments'
ALTER TABLE [dbo].[DeliveryDocuments]
ADD CONSTRAINT [PK_DeliveryDocuments]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'InvoiceDocuments'
ALTER TABLE [dbo].[InvoiceDocuments]
ADD CONSTRAINT [PK_InvoiceDocuments]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DocumentRows'
ALTER TABLE [dbo].[DocumentRows]
ADD CONSTRAINT [PK_DocumentRows]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Items'
ALTER TABLE [dbo].[Items]
ADD CONSTRAINT [PK_Items]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Warehouses'
ALTER TABLE [dbo].[Warehouses]
ADD CONSTRAINT [PK_Warehouses]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Journals'
ALTER TABLE [dbo].[Journals]
ADD CONSTRAINT [PK_Journals]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'JournalTypes'
ALTER TABLE [dbo].[JournalTypes]
ADD CONSTRAINT [PK_JournalTypes]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Customers'
ALTER TABLE [dbo].[Customers]
ADD CONSTRAINT [PK_Customers]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Vouchers'
ALTER TABLE [dbo].[Vouchers]
ADD CONSTRAINT [PK_Vouchers]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CollectionMoneys'
ALTER TABLE [dbo].[CollectionMoneys]
ADD CONSTRAINT [PK_CollectionMoneys]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [OrderDocumentId] in table 'DeliveryDocuments'
ALTER TABLE [dbo].[DeliveryDocuments]
ADD CONSTRAINT [FK_OrderDocumentDeliveryDocument]
    FOREIGN KEY ([OrderDocumentId])
    REFERENCES [dbo].[OrderDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderDocumentDeliveryDocument'
CREATE INDEX [IX_FK_OrderDocumentDeliveryDocument]
ON [dbo].[DeliveryDocuments]
    ([OrderDocumentId]);
GO

-- Creating foreign key on [DeliveryDocumentId] in table 'InvoiceDocuments'
ALTER TABLE [dbo].[InvoiceDocuments]
ADD CONSTRAINT [FK_DeliveryDocumentInvoiceDocument]
    FOREIGN KEY ([DeliveryDocumentId])
    REFERENCES [dbo].[DeliveryDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DeliveryDocumentInvoiceDocument'
CREATE INDEX [IX_FK_DeliveryDocumentInvoiceDocument]
ON [dbo].[InvoiceDocuments]
    ([DeliveryDocumentId]);
GO

-- Creating foreign key on [InvoiceDocumentId] in table 'CollectionMoneys'
ALTER TABLE [dbo].[CollectionMoneys]
ADD CONSTRAINT [FK_InvoiceDocumentCollectionMoney]
    FOREIGN KEY ([InvoiceDocumentId])
    REFERENCES [dbo].[InvoiceDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoiceDocumentCollectionMoney'
CREATE INDEX [IX_FK_InvoiceDocumentCollectionMoney]
ON [dbo].[CollectionMoneys]
    ([InvoiceDocumentId]);
GO

-- Creating foreign key on [VoucherId] in table 'CollectionMoneys'
ALTER TABLE [dbo].[CollectionMoneys]
ADD CONSTRAINT [FK_VoucherCollectionMoney]
    FOREIGN KEY ([VoucherId])
    REFERENCES [dbo].[Vouchers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VoucherCollectionMoney'
CREATE INDEX [IX_FK_VoucherCollectionMoney]
ON [dbo].[CollectionMoneys]
    ([VoucherId]);
GO

-- Creating foreign key on [DeliveryDocumentId] in table 'DocumentRows'
ALTER TABLE [dbo].[DocumentRows]
ADD CONSTRAINT [FK_DeliveryDocumentDocumentRow]
    FOREIGN KEY ([DeliveryDocumentId])
    REFERENCES [dbo].[DeliveryDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_DeliveryDocumentDocumentRow'
CREATE INDEX [IX_FK_DeliveryDocumentDocumentRow]
ON [dbo].[DocumentRows]
    ([DeliveryDocumentId]);
GO

-- Creating foreign key on [InvoiceDocumentId] in table 'DocumentRows'
ALTER TABLE [dbo].[DocumentRows]
ADD CONSTRAINT [FK_InvoiceDocumentDocumentRow]
    FOREIGN KEY ([InvoiceDocumentId])
    REFERENCES [dbo].[InvoiceDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_InvoiceDocumentDocumentRow'
CREATE INDEX [IX_FK_InvoiceDocumentDocumentRow]
ON [dbo].[DocumentRows]
    ([InvoiceDocumentId]);
GO

-- Creating foreign key on [OrderDocumentId] in table 'DocumentRows'
ALTER TABLE [dbo].[DocumentRows]
ADD CONSTRAINT [FK_OrderDocumentDocumentRow]
    FOREIGN KEY ([OrderDocumentId])
    REFERENCES [dbo].[OrderDocuments]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_OrderDocumentDocumentRow'
CREATE INDEX [IX_FK_OrderDocumentDocumentRow]
ON [dbo].[DocumentRows]
    ([OrderDocumentId]);
GO

-- Creating foreign key on [ItemId] in table 'DocumentRows'
ALTER TABLE [dbo].[DocumentRows]
ADD CONSTRAINT [FK_ItemDocumentRow]
    FOREIGN KEY ([ItemId])
    REFERENCES [dbo].[Items]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ItemDocumentRow'
CREATE INDEX [IX_FK_ItemDocumentRow]
ON [dbo].[DocumentRows]
    ([ItemId]);
GO

-- Creating foreign key on [JournalType_Id] in table 'Journals'
ALTER TABLE [dbo].[Journals]
ADD CONSTRAINT [FK_JournalJournalType]
    FOREIGN KEY ([JournalType_Id])
    REFERENCES [dbo].[JournalTypes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_JournalJournalType'
CREATE INDEX [IX_FK_JournalJournalType]
ON [dbo].[Journals]
    ([JournalType_Id]);
GO

-- Creating foreign key on [JournalId] in table 'InvoiceDocuments'
ALTER TABLE [dbo].[InvoiceDocuments]
ADD CONSTRAINT [FK_JournalInvoiceDocument]
    FOREIGN KEY ([JournalId])
    REFERENCES [dbo].[Journals]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_JournalInvoiceDocument'
CREATE INDEX [IX_FK_JournalInvoiceDocument]
ON [dbo].[InvoiceDocuments]
    ([JournalId]);
GO

-- Creating foreign key on [JournalId] in table 'Vouchers'
ALTER TABLE [dbo].[Vouchers]
ADD CONSTRAINT [FK_JournalVoucher]
    FOREIGN KEY ([JournalId])
    REFERENCES [dbo].[Journals]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_JournalVoucher'
CREATE INDEX [IX_FK_JournalVoucher]
ON [dbo].[Vouchers]
    ([JournalId]);
GO

-- Creating foreign key on [CustomerId] in table 'OrderDocuments'
ALTER TABLE [dbo].[OrderDocuments]
ADD CONSTRAINT [FK_CustomerOrderDocument]
    FOREIGN KEY ([CustomerId])
    REFERENCES [dbo].[Customers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CustomerOrderDocument'
CREATE INDEX [IX_FK_CustomerOrderDocument]
ON [dbo].[OrderDocuments]
    ([CustomerId]);
GO

-- Creating foreign key on [CustomerId] in table 'DeliveryDocuments'
ALTER TABLE [dbo].[DeliveryDocuments]
ADD CONSTRAINT [FK_CustomerDeliveryDocument]
    FOREIGN KEY ([CustomerId])
    REFERENCES [dbo].[Customers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CustomerDeliveryDocument'
CREATE INDEX [IX_FK_CustomerDeliveryDocument]
ON [dbo].[DeliveryDocuments]
    ([CustomerId]);
GO

-- Creating foreign key on [CustomerId] in table 'InvoiceDocuments'
ALTER TABLE [dbo].[InvoiceDocuments]
ADD CONSTRAINT [FK_CustomerInvoiceDocument]
    FOREIGN KEY ([CustomerId])
    REFERENCES [dbo].[Customers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CustomerInvoiceDocument'
CREATE INDEX [IX_FK_CustomerInvoiceDocument]
ON [dbo].[InvoiceDocuments]
    ([CustomerId]);
GO

-- Creating foreign key on [CustomerId] in table 'Vouchers'
ALTER TABLE [dbo].[Vouchers]
ADD CONSTRAINT [FK_CustomerVoucher]
    FOREIGN KEY ([CustomerId])
    REFERENCES [dbo].[Customers]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CustomerVoucher'
CREATE INDEX [IX_FK_CustomerVoucher]
ON [dbo].[Vouchers]
    ([CustomerId]);
GO

-- Creating foreign key on [WarehouseId] in table 'Items'
ALTER TABLE [dbo].[Items]
ADD CONSTRAINT [FK_WarehouseItem]
    FOREIGN KEY ([WarehouseId])
    REFERENCES [dbo].[Warehouses]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_WarehouseItem'
CREATE INDEX [IX_FK_WarehouseItem]
ON [dbo].[Items]
    ([WarehouseId]);
GO

ALTER Table dbo.Customers
add default (NEWID()) for Id

GO

ALTER Table dbo.CollectionMoneys
add default (NEWID()) for Id

go

ALTER Table dbo.DeliveryDocuments
add default (NEWID()) for Id

GO

ALTER Table dbo.DocumentRows
add default (NEWID()) for Id

GO

ALTER Table dbo.InvoiceDocuments
add default (NEWID()) for Id

GO

ALTER Table dbo.Items
add default (NEWID()) for Id

GO

ALTER Table dbo.Journals
add default (NEWID()) for Id

go

ALTER Table dbo.JournalTypes
add default (NEWID()) for Id

GO

ALTER Table dbo.OrderDocuments
add default (NEWID()) for Id

GO

ALTER Table dbo.Vouchers
add default (NEWID()) for Id

GO

ALTER Table dbo.Warehouses
add default (NEWID()) for Id
-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------